﻿#include "cameraconfig.h"
#include "ui_cameraconfig.h"
#include<QPushButton>
#include"cameraconfigadd.h"
CameraConfig::CameraConfig(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::CameraConfig)
{
    ui->setupUi(this);


    ui->buttonBox->button(QDialogButtonBox::Ok)->setText("确定");
    ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("取消");

    QFont font =  ui->tableWidget->horizontalHeader()->font();                                   //获取字体格式
    font.setBold(true);

    ui->tableWidget->verticalHeader()->setVisible(false);                                           //设置tableWidget左侧行标签隐藏
    ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);                            //设置tableWidget内容外部不可编辑
    ui->tableWidget->horizontalHeader()->setStyleSheet("QHeaderView::section{background:#404040;color:#ffffff}");//设置表头背景和字体颜色
    ui->tableWidget->horizontalHeader()->setFont(font);                                             //设置表头字体加粗
    ui->tableWidget->setFont(QFont("song", 12));                                                    //设置表头字体大小为12号


    ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);      //自适应列宽
    ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);    //自适应行宽
}

CameraConfig::~CameraConfig()
{
    delete ui;
}

void CameraConfig::on_actionAdd_triggered()
{
    CameraConfigAdd *a=new CameraConfigAdd;
    a->setWindowTitle("增加相机");
    a->show();
}

void CameraConfig::on_buttonBox_clicked(QAbstractButton *button)
{
        if(button == static_cast<QAbstractButton *>(ui->buttonBox->button(QDialogButtonBox::Ok)))
            {
                this->close();
            }
            else if(button == ui->buttonBox->button(QDialogButtonBox::Cancel))
            {
                this->close();
            }
}
